//
//  QYXBaseNavigationController.m
//  OpenYourEyes
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 Google AdWords. All rights reserved.
//

#import "QYXBaseNavigationController.h"
#import <objc/runtime.h>

@interface QYXBaseNavigationController ()

@end

@implementation QYXBaseNavigationController

#pragma mark -侧滑范围变大
- (void)setRecognizerForScreen{
    
    // 获取系统自带滑动手势的target对象
    id target = self.interactivePopGestureRecognizer.delegate;
    // 创建全屏滑动手势，调用系统自带滑动手势的target的action方法
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
    // 设置手势代理，拦截手势触发
    pan.delegate = self;
    // 给导航控制器的view添加全屏滑动手势
    [self.view addGestureRecognizer:pan];
    // 禁止使用系统自带的滑动手势
    self.interactivePopGestureRecognizer.enabled = NO;
    
    // 在根控制器器如果在右侧按住向右滑动，然后再点击 PUSH 按钮，则无法 PUSH 出新的控制器
    // 解决办法
    
    // 1. 设置 interactivePopGestureRecognizer 的代理
    // 2. 实现代理方法，并且在根视图控制器时不支持手势返回
    self.interactivePopGestureRecognizer.delegate = self;
    
}



- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setRecognizerForScreen];
    
    //将透明效果去掉
    [self.navigationBar setTranslucent:YES];
    
   
    //修改字体
    //    self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
    //修改文字
    
}

// 状态栏样式

//- (UIStatusBarStyle)preferredStatusBarStyle {
//    return UIStatusBarStyleLightContent;
//}

#pragma mark - UIGestureRecognizerDelegate
// 手势识别将要开始
//
// @param gestureRecognizer 手势识别
//
// @return 返回 NO，放弃当前识别到的手势

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    
    // 如果是根视图控制器，则不支持手势返回
    return self.childViewControllers.count > 1;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
